package org.github.p2w.entity;

import lombok.Data;

import java.util.List;

/**
 * 请求
 *
 * @author xiayongchao
 * @date 2022/08/02
 */
@Data
public class Request {

    private String method;

    private Body body;

    private Url url;

    private List<Header> header;

    public String getHeaderParams() {
        if (header == null || header.isEmpty()) {
            return "";
        }
        StringBuilder params = new StringBuilder();
        header.forEach(h -> params.append(h.getKey())
                .append(":")
                .append(h.getValue())
                .append("\n"));
        return params.substring(0, params.length() - 2);
    }

}
